package shun.demo.intent;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import org.apache.http.protocol.HTTP;
import shun.demo.R;

/**
 * Created by chen on 3/4/14.
 */
public class IntentActivity extends Activity implements View.OnClickListener {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.intent);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tel:
                Uri number = Uri.parse("tel:10086");
                Intent callIntent = new Intent(Intent.ACTION_DIAL, number);
                startActivity(callIntent);
                break;

            case R.id.map:
                // Map point based on address
                Uri location = Uri.parse("geo:0,0?q=1600+Amphitheatre+Parkway,+Mountain+View,+California");
                // Or map point based on latitude/longitude
                // Uri location = Uri.parse("geo:37.422219,-122.08364?z=14"); // z param is zoom level
                Intent mapIntent = new Intent(Intent.ACTION_VIEW, location);
                startActivity(mapIntent);
                break;

            case R.id.web:
                Uri webPage = Uri.parse("http://www.baidu.com");
                Intent webIntent = new Intent(Intent.ACTION_VIEW, webPage);
                startActivity(webIntent);
                break;

            case R.id.share:
                Intent intent = new Intent(Intent.ACTION_SEND);
                intent.setType(HTTP.PLAIN_TEXT_TYPE);
                startActivity(intent);
                break;

            case R.id.share_chooser:
                Intent shareIntent = new Intent(Intent.ACTION_SEND);
                shareIntent.setType(HTTP.PLAIN_TEXT_TYPE);
                Intent chooser = Intent.createChooser(shareIntent, null);
                startActivity(chooser);
                break;

            default:
                break;
        }
    }
}